package SSF.OS.NetFlow.Util;

import java.util.*;

/**
 * A small gadget tempararily written to sort the flow records according to
 * the "First" field. The "First" field shows at what time the flow starts.
 */
public class FlowComparator implements Comparator 
{
    @Override
	public boolean equals(Object obj)
    {
	return super.equals(obj);
    }

    @Override
	public int compare(Object o1, Object o2)
    {
	try {
	    IpNetFlow nf1 = (IpNetFlow)o1;
	    IpNetFlow nf2 = (IpNetFlow)o2;

	    float tmp = nf1.First - nf2.First;
	    if (tmp == 0)
		return 0;
	    if (tmp > 0)
		return 1;
	    else return -1;

	} catch (Exception any) {
	    System.err.println(any.getMessage());
	    any.printStackTrace();
	    System.exit(-1);
	}
	return 0;
    }
}

